﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;

namespace PickGold.Generic
{
	public class CDictionary<TKey, TValue> : IDictionary<TKey, TValue>
	{
		const int CAPACITY = 10;

		private KeyValuePair<TKey, TValue>[] _List;
		private int _Count;
		private int _Capacity;

		public CDictionary() : this(CAPACITY) { }
		public CDictionary(int capacity)
		{
			this._Capacity = capacity;
			this.Clear();
		}
		public CDictionary(IDictionary<TKey, TValue> collection)
			: this()
		{
			foreach (var item in collection)
				this.Add(item);
		}

		private void Check(bool isAdd)
		{
			if (isAdd)
			{
				if (this._Count < this._List.Length)
					return;

				var os0 = new KeyValuePair<TKey, TValue>[this._Count + CAPACITY];
				this._List.CopyTo(os0, 0);
				this._List = os0;
				return;
			}

			if (this._Capacity >= this._Count)
				return;

			if (this._Count > this._List.Length - CAPACITY)
				return;

			var os = new KeyValuePair<TKey, TValue>[this._Count + CAPACITY];
			for (var i = 0; i < this._Count; i++)
				os[i] = this._List[i];
			//this._List.CopyTo(os, 0);
			this._List = os;
		}

		#region IDictionary<TKey,TValue> 成员

		public void Add(TKey key, TValue value)
		{
			throw new NotImplementedException();
		}

		public bool ContainsKey(TKey key)
		{
			throw new NotImplementedException();
		}

		public ICollection<TKey> Keys
		{
			get { throw new NotImplementedException(); }
		}

		public bool Remove(TKey key)
		{
			throw new NotImplementedException();
		}

		public bool TryGetValue(TKey key, out TValue value)
		{
			throw new NotImplementedException();
		}

		public ICollection<TValue> Values
		{
			get { throw new NotImplementedException(); }
		}

		public TValue this[TKey key]
		{
			get
			{
				throw new NotImplementedException();
			}
			set
			{
				throw new NotImplementedException();
			}
		}

		#endregion

		#region ICollection<KeyValuePair<TKey,TValue>> 成员

		public void Add(KeyValuePair<TKey, TValue> item)
		{
			throw new NotImplementedException();
		}

		public void Clear()
		{
			throw new NotImplementedException();
		}

		public bool Contains(KeyValuePair<TKey, TValue> item)
		{
			throw new NotImplementedException();
		}

		public void CopyTo(KeyValuePair<TKey, TValue>[] array, int arrayIndex)
		{
			throw new NotImplementedException();
		}

		public int Count
		{
			get { throw new NotImplementedException(); }
		}

		public bool IsReadOnly
		{
			get { throw new NotImplementedException(); }
		}

		public bool Remove(KeyValuePair<TKey, TValue> item)
		{
			throw new NotImplementedException();
		}

		#endregion

		#region IEnumerable<KeyValuePair<TKey,TValue>> 成员

		public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator()
		{
			throw new NotImplementedException();
		}

		#endregion

		#region IEnumerable 成员

		IEnumerator IEnumerable.GetEnumerator()
		{
			throw new NotImplementedException();
		}

		#endregion
	}
}
